package com.studypartner.tasks;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class DailyTaskManager {

	private int dayID;
	// private static ArrayList<DailyTask> tasks = new ArrayList<DailyTask>();
	private static HashMap<String, DailyTask> tasks = new HashMap<String, DailyTask>();

	public void addTask(int dayid, Task task, int dailyNum, int currentNum) {
		tasks.put(getKey(dayid, task.getTaskName()), new DailyTask(dayid, task,
				dailyNum, currentNum));
	}

	public String getKey(int dayid2, String taskName) {
		// TODO Auto-generated method stub
		String key = "";
		key += dayid2;
		key += taskName;
		return key;
	}

	public int getDayID() {
		return dayID;
	}

	public void setDayID(int dayID) {
		this.dayID = dayID;
	}

	public void clear() {
		tasks.clear();
	}

	public DailyTask getTask(int dayid, String taskName) {
		return tasks.get(getKey(dayid, taskName));
	}

	public ArrayList<DailyTask> getTasks() {
		ArrayList<DailyTask> dailyTasks = new ArrayList<DailyTask>();
		Iterator<?> iter = tasks.entrySet().iterator();
		while (iter.hasNext()) {
			Map.Entry entry = (Map.Entry) iter.next();
			dailyTasks.add((DailyTask) entry.getValue());
		}
		return dailyTasks;
	}
}
